import 'dart:isolate';
import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:myapp/model/SearchResultModel.dart';
import 'package:myapp/util/PageUtil.dart';
import 'package:myapp/util/Utils.dart';

class SearchResultItem extends StatelessWidget {
  Goods_listBean itemData;

  SearchResultItem(Goods_listBean listBean) {
    itemData = listBean;
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        PageUtil.toGoodsDetailPage(context, itemData.searchId, itemData.goodsId);
      },
      child: Container(
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Image.network(itemData.goodsImageUrl),
            Expanded(
              child: Container(
                padding: const EdgeInsets.only(left: 8),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      itemData.goodsName,
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                    ),
                    Expanded(
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.end,
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                          Text(
                            "￥" +
                                Utils.formatNum(
                                    0.01 *
                                        (itemData.minGroupPrice -
                                            itemData.couponDiscount),
                                    2),
                            style: TextStyle(fontSize: 18, color: Colors.red),
                          ),
                          Text(
                            "券后 ",
                            style: TextStyle(fontSize: 10, color: Colors.grey),
                          ),
                        ],
                      ),
                    ),
                    Expanded(
                      child: Row(
                        children: <Widget>[
                          Text(
                            "优惠券" + (0.01 * itemData.couponDiscount).toString(),
                            style: TextStyle(
                              fontSize: 14,
                              color: Colors.redAccent,
//                          decoration: TextDecoration.lineThrough,
//                          decorationColor: const Color(0xff000000),
                            ),
                          ),
                          Text(
                            "数量" + itemData.couponDiscount.toString(),
                            style: TextStyle(
                              fontSize: 12,
                              color: Colors.grey,
//                          decoration: TextDecoration.lineThrough,
//                          decorationColor: const Color(0xff000000),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
